function tribonacciSequence(startSequence, length) {
  if (length === 0) {
    return [];
  } else if (length <= 3) {
    return startSequence.slice(0, length);
  } else {
    for (let i = 3; i < length; i++) {
      let copy = [...startSequence];
      let copyLength = copy.length;
      startSequence.push(copy[copyLength-1] + copy[copyLength-2] + copy[copyLength-3]);
    }
  }
  return startSequence;
}


console.log(tribonacciSequence([0, 0, 1], 20));
console.log(tribonacciSequence([21, 32, 43], 1));
console.log(tribonacciSequence([0, 0, 1], 0));
